<template>
  <div class="table-wrapper clearfix">
    <el-table v-loading="loading" :data="data" height="calc(100vh - 240px)">
      <el-table-column
        v-if="addNumber"
        type="index"
        label="序号"
        width="50"
      />
      <slot />
    </el-table>

    <!-- <div class="table-pagination-wrapper fr mt-20">
      <el-pagination
        background
        layout="prev, pager, next"
        :total="total"
        :page-size="pageSize"
        @current-change="handleCurrentChange"
        @selection-change="handleSelectionChange"
        :current-page.sync="currentPage"
      ></el-pagination>
    </div> -->
  </div>
</template>

<script>
/**
 * element-ui table 二次封装
 */
export default {
  name: 'MTable',
  props: {
    total: {
      type: Number,
      default: 0
    },
    data: {
      type: Array,
      default: () => []
    },
    loading: {
      type: Boolean,
      default: false
    },
    pageSize: {
      type: Number,
      default: 10
    },
    addNumber: {
      type: Boolean,
      default: false
    }
  },
  data() {
    return {
      currentPage: 1
    };
  },
  methods: {
    handleCurrentChange(val) {
      this.$emit('current-change', val);
    },
    handleSelectionChange(val) {
      this.$emit('selection-change', val);
    }
  }
};
</script>
